<template>
  <div>
    <ul>
      <!-- 用每一项的唯一标识作为key，可以最大限度的复用dom -->
      <li v-for="(item,index) in list" :key="item">
         {{ item }}
      <button @click="delte(index)">删除</button>
      </li>
    </ul>
    <button @click="addFn">生成</button>
  </div>
</template>
<script>
export default {
data(){
  return{
    list:[ 1, 5, 3 ]
  }
},
methods:{
  addFn(){
    // let random = Math.floor(Math.random() * arr.length)
const random =  Math.floor(Math.random() * 3)
    this.list.push(random)
  },
  delte(index){
    this.list.splice(index,1)
  }
}
}
</script>

<style>

</style>